# 指定编译器
CC = aarch64-linux-gnu-gcc
CXX = aarch64-linux-gnu-g++

# 编译器标志，例如：-g -Wall (调试，警告全开)
CFLAGS = -g -Wall -fno-omit-frame-pointer
CXXFLAGS = -g -Wall -fno-omit-frame-pointer

# 链接器标志，例如：-L/usr/lib -lm (指定库搜索路径，链接数学库)
LDFLAGS = -L../build
LDLIBS = -lm -l:libframeParse.a

# 指定头文件目录
INCLUDES = -I../

# 源文件和对象文件
C_SOURCES = $(wildcard *.c)
CPP_SOURCES = $(wildcard *.cpp)
C_OBJECTS = $(C_SOURCES:.c=.o)
CPP_OBJECTS = $(CPP_SOURCES:.cpp=.o)
OBJECTS = $(addprefix build/,$(C_OBJECTS) $(CPP_OBJECTS))

# 目标二进制文件名和目标目录
TARGET = app
TARGET_DIR = build
TARGET_PATH = $(TARGET_DIR)/$(TARGET)

# 默认目标
all: $(TARGET_DIR) $(TARGET_PATH)

$(TARGET_DIR):
	mkdir -p $(TARGET_DIR)

$(TARGET_PATH): $(OBJECTS)
	$(CXX) $(LDFLAGS) -o $@ $^ $(LDLIBS)

# 编译.c文件
build/%.o: %.c
	$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@

# 编译.cpp文件
build/%.o: %.cpp
	$(CXX) $(CXXFLAGS) $(INCLUDES) -c $< -o $@

# 清理编译生成的文件
clean:
	rm -rf $(TARGET_DIR)

.PHONY: all clean
